# Contributor: Aaron Fischer <mail@aaron-fischer.net>
# Maintainer: Aaron Fischer <mail@aaron-fischer.net>
pkgname=freeglut
pkgver=3.4.0
pkgrel=4
pkgdesc="free reimplementation of OpenGL Utility Toolkit (GLUT) library"
url="https://freeglut.sourceforge.net/"
arch="all"
options="!check" # No test suite.
license="MIT"
depends_dev="mesa-dev libx11-dev libice-dev libxxf86vm-dev libxi-dev glu-dev"
makedepends="$depends_dev cmake samurai"
subpackages="$pkgname-dev"
source="https://downloads.sourceforge.net/freeglut/freeglut-$pkgver.tar.gz"

build() {
	CFLAGS="$CFLAGS -flto=auto" \
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DFREEGLUT_BUILD_STATIC_LIBS=0
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	# Symlink glut.pc to freeglut.pc for backwards compatibility
	ln -s glut.pc "$pkgdir"/usr/lib/pkgconfig/freeglut.pc
}

sha512sums="
4bb6d6c086bac7a9c0ec78062dce58987555785abe6375f462ee249f65210a964a28fb10ba7ee8a42d7fafb00eb8d196eb403d65d255f02f88467369c187228b  freeglut-3.4.0.tar.gz
"
